package com.hyyt.shopjsp.util.procedure.service.impl;

import com.hyyt.shopjsp.util.procedure.dao.CallProcedureDao;
import com.hyyt.shopjsp.util.procedure.service.ICallProcedureService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;


/**
 * ICallProcedureService 调用存储过程的Service接口类
 * @author
 *
 */
@Transactional
@Service
public class CallProcedureService implements ICallProcedureService {
	@Resource
	private CallProcedureDao callProcedureDao;

	/**
	 * 根据用户id查询 现金钱包 总余额
	 *
	 * @param customer_id
	 * @return
	 */
	@Override
	public BigDecimal updateOrGetCustomerBalanceByCustomerId(Integer customer_id)  {
		//调用函数获得结果
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("customer_id", customer_id);
		paramMap.put("balanceNow", -1);
		BigDecimal result = callProcedureDao.getCustomerBalanceByCustomerId(paramMap);
		return result;
	}

	/**
	 * 根据用户id查询 积分（金币） 总额
	 *
	 * @param customer_id
	 * @return
	 * @throws Exception
	 */
	@Override
	public BigDecimal updateOrGetBalanceCoinByCustomerId(Integer customer_id) {
		//调用函数获得结果
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("customer_id", customer_id);
		paramMap.put("mallCoinNow", -1);
		BigDecimal result = callProcedureDao.getBalanceCoinByCustomerId(paramMap);
		return result;
	}

}
